Learning Vim Daily
Table of Contents
Table of Contents
Learning Vim
A Little Rambling Before I Start
I'm finally learning Vim!! I've wanted to ditch the mouse while coding for ages, especially the scroll wheel. Taking my hand off the keyboard and putting it back really interrupts the experience... So let's play with Vim. I'll note down a few little commands before I forget them.
DAY 1
It's surprisingly hard to find a mnemonic for H J K L. For now, I can only get used to them through the most basic rote memorization.

H is furthest left, L furthest right, J has a downward hook, and K is the one left over, so it goes up...
Vim has three modes. I already know a little from using Linux before.
- Type : to enter command mode.
:wqsaves directly; apparently: 1jumps to the first line. - Type i to enter insert mode.
Once you're in insert mode, typing is much like anywhere else. But some shortcuts don't seem to work, such as ctrl+A to select all. Vim has its own command for that. - Type v to enter visual mode.
I haven't figured out what it's for yet. I'll have a look later.

DAY 2
dd deletes the current line.
gg goes to the first line.
u undoes.
This feels so unfamiliar 😵💫. These have to be used in normal mode.
DAY 3
p pastes directly.
dG deletes all the lines below. Combine it with gg to go to the start and delete everything.
I don't even know how to select all in nano... Vim's starting to come in handy 🥰.
DAY 4
Then type yG. If you see xx lines yanked, as in the screenshot, it worked.

But that only puts the text in a Vim register. For the VS Code Vim extension, you need to enable this:
"vim.useSystemClipboard": true
to copy to the system clipboard.
Of course, you can also use "+yG to copy straight to the system clipboard, but I find that a hassle.

Getting more and more used to coding in Vim 🥰
DAY 5
0 goes to the start of the line.
$ or end goes to the end of the line.
G moves down to the last line.
gg goes back to the first line.
nG, with a number, goes to line n.
n<space> goes to the nth character on the line.
DAY 6
A jumps straight to the end of the line and starts editing.
g_ also goes to the last character.